//--------------------------------------------------------------------------------------
// Constant Buffer Variables
//--------------------------------------------------------------------------------------
//cbuffer cb1
//{
	matrix World;
	matrix View;
	matrix Projection;
	
//};

Texture2D				g_txDiffuse;
float4					g_vAmbientColor = { 1.0f, 1.0f, 1.0f, 1.0f };
float4					g_cMaterial		= { 1.0f, 1.0f, 1.0f, 1.0f };
float					g_fTime	= 1.0f;
SamplerState samLinear
{
    Filter = MIN_MAG_MIP_LINEAR;
    AddressU = Wrap;
    AddressV = Wrap;
};

//--------------------------------------------------------------------------------------
struct NO_TEX_VS_OUTPUT
{
    float4 p : SV_POSITION;
    float4 c : COLOR0;
};

struct VS_OUTPUT
{
    float4 p : SV_POSITION;
    float4 c : COLOR0;
    float2 t : TEXCOORD;
};

struct VS_INPUT
{
    float3 p : POSITION;
    float4 c : COLOR0;
    float2 t : TEXCOORD0;
};

//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
VS_OUTPUT VS( float3 p : POSITION, float4 c : COLOR0, float2 t : TEXCOORD0)
{
    VS_OUTPUT output = (VS_OUTPUT)0;
    output.p = mul( float4( p, 1 ), World );   
    output.p = mul( output.p, View );
    output.p = mul( output.p, Projection );
    output.c = c;
    output.t  = t;
    return output;
}
//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------

NO_TEX_VS_OUTPUT COLOR_VS( float4 p : POSITION, float4 c : COLOR )
{
    NO_TEX_VS_OUTPUT output = (NO_TEX_VS_OUTPUT)0;
    output.p = mul( p, World );   
    output.p = mul( output.p, View );
    output.p = mul( output.p, Projection );
    output.c = c;
    return output;
}
//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 PS( VS_OUTPUT input ) : SV_Target
{
    //return g_txDiffuse.Sample( samLinear, input.t ) * input.c * g_vAmbientColor;
	float4 fFinalColor	= g_txDiffuse.Sample( samLinear, input.t ) * input.c * g_cMaterial;
    return fFinalColor;
}
//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 COLOR_PS( NO_TEX_VS_OUTPUT input ) : SV_Target
{
    return input.c * g_vAmbientColor;
}
//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 AmbientColor( VS_OUTPUT input ) : SV_Target
{
   return input.c * g_vAmbientColor;
}
//--------------------------------------------------------------------------------------
technique10 ColorRender
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_4_0, COLOR_VS() ) );
        SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_4_0, COLOR_PS() ) );
    }
}
//--------------------------------------------------------------------------------------
technique10 AmbientColorRender
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_4_0, VS() ) );
        SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_4_0, AmbientColor() ) );
    }
}
//--------------------------------------------------------------------------------------
technique10 Render
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_4_0, VS() ) );
        SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_4_0, PS() ) );
    }
}

